package com.wuyou.designPatterns.template;

public class StringDisplay extends AbstractDisplay{

    private String s;
    private int width;

    public StringDisplay(String s) {
        this.s = s;
        this.width = s.getBytes().length;
    }

    public String getS() {
        return s;
    }

    public void setS(String s) {
        this.s = s;
        this.width = s.getBytes().length;
    }

    @Override
    void open() {
        printLine();
    }

    @Override
    void print() {
        System.out.println("|" + s + "|");
    }

    @Override
    void close() {
        printLine();
    }

    private void printLine(){
        System.out.print("+");
        for(int i=0;i<width;i++){
            System.out.print("-");
        }
        System.out.println("+");
    }
}
